from urllib import request

# response=request.urlopen("http://httpbin.org/get")没有data就是get，有data就是post
# response=request.urlopen("http://httpbin.org/post",data=b"username=12311")
#
# print(response.getcode())
# print(response.info())
# print(response.geturl)
# print(response.read())#获取响应返回的响应数据 只能读一次
# 完整的网络请求
# 1.构造请求对象
headers={}
req=request.Request("http://httpbin.org/post",data=b"123",headers=headers,method="POST")

# 2.发送请求
response=request.urlopen(req)

print(response,"收到响应")
print(response.read())
print("second",response.read())